package com.tanhua.commons.config;

import com.tanhua.commons.properties.*;
import com.tanhua.commons.templates.*;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.listener.RedisMessageListenerContainer;

@Configuration
@EnableConfigurationProperties(value = {SmsProperties.class,
        OssProperties.class, AipFaceProperties.class, HuanXinProperties.class, HuaWeiUGCProperties.class})
public class TanhuaAutoConfiguration {



    @Bean
    public SmsTemplate createSmsTemplate(SmsProperties smsProperties){
        SmsTemplate smsTemplate = new SmsTemplate(smsProperties);
        return smsTemplate;
    }

    @Bean
    public OssTemplate ossTemplate(OssProperties ossProperties){
        OssTemplate ossTemplate = new OssTemplate(ossProperties);
        return ossTemplate;
    }

    @Bean
    public AipFaceTemplate aipFaceTemplate(AipFaceProperties aipFaceProperties){
        AipFaceTemplate aipFaceTemplate = new AipFaceTemplate(aipFaceProperties);
        return aipFaceTemplate;
    }


    @Bean
    public HuanXinTemplate huanXinTemplate(HuanXinProperties huanXinProperties){
        HuanXinTemplate huanXinTemplate = new HuanXinTemplate(huanXinProperties);
        return huanXinTemplate;
    }

    @Bean
    public HuaWeiUGCTemplate huaWeiUGCTemplate(HuaWeiUGCProperties huaWeiUGCProperties){
        HuaWeiUGCTemplate huaWeiUGCTemplate = new HuaWeiUGCTemplate(huaWeiUGCProperties);
        return huaWeiUGCTemplate;
    }
    //监听
    @Bean
    RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) {
        RedisMessageListenerContainer container = new RedisMessageListenerContainer();
        container.setConnectionFactory(connectionFactory);
        return container;
    }
}
